package com.xuanheng.utils.http.async;


import android.text.TextUtils;


import com.xuanheng.utils.LogUtils;

import java.io.IOException;

/**
 * An HttpRequest representing a standard GET request.
 * This does not need any special treatment except for query parameters, which it adds on to
 *
 * @author Nikki
 */
public class HttpGetRequest extends HttpRequest {

    public HttpGetRequest(String url) {
        super(url);
    }

    @Override
    public void execute() throws IOException {
        // GET only needs to add headers and possibly a query string
        if (!TextUtils.isEmpty(url)) {
            int firstIdx = url.indexOf('?');
            if (firstIdx == -1) {
                url += "?";
            }
            if (parameters != null) {
                if (!parameters.isEmpty()) {
                    url += parameters.toURLEncodedString();
                }
            }
        }
        LogUtils.e("HttpGetRequest",url);
        openConnection();
    }
}
